/**
 * 
 */
package com.wsmhz.web.aspect;

import java.util.Date;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * create by tangbj on 2018/3/25
 * 每个API都会处理的时间切面
 */
//@Aspect
//@Component
public class ApiTimeAspect {

	private static Logger logger = LoggerFactory.getLogger(ApiTimeAspect.class);
	
	@Around("execution(* com.wsmhz.web.controller..*.*(..))")
	public Object handleControllerMethod(ProceedingJoinPoint pjp) throws Throwable {
		logger.info("ApiTimeAspect start");
		Object[] args = pjp.getArgs();
		for (Object arg : args) {
			logger.info("ApiTimeAspect arg is "+arg);
		}
		long start = new Date().getTime();
		Object object = pjp.proceed();
		logger.info("ApiTimeAspect 耗时:"+ (new Date().getTime() - start));
		logger.info("ApiTimeAspect end");
		return object;
	}

}
